<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>财务管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="./static/css/font.css">
    <link rel="stylesheet" href="./static/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./static/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body class="layui-anim layui-anim-up">
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">财务管理</a>
        <a>
          <cite>财务管理</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md14 x-so" onsubmit="return false;">
            <div class="layui-inline">
                <lable class="layui-form-label">操作信息：</lable>
                <input type="text" name="keyBillAction" placeholder="请输入操作信息" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-inline">
              <lable class="layui-form-label">类型：</lable>
              <div class="layui-input-inline">
                <select name="keywordBillType" lay-verify="required">
                    <option value="-1">所有</option>
                    <option value="0">支出</option>
                    <option value="1">收入</option>
                </select>
              </div>
            </div>
            <button class="layui-btn" id="btn-seach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <xblock>
        <button class="layui-btn" onclick="x_admin_show('添加信息','${pageContext.request.contextPath}/bill?m=addPage',560,560)"><i class="layui-icon"></i>添加</button>
    </xblock>
    <table class="layui-table" lay-filter="action" id="data-table"></table>

</div>
<script>
    layui.use(['table','form'], function () {
        $ = layui.jquery;
        var form = layui.form
        // 数据表格
        var table = layui.table;

        //第一个实例
        var tableIns = table.render({
            elem: '#data-table'
            , height: 480
            , url: '${pageContext.request.contextPath}/bill?m=findBillByParam' //数据接口
            , page: true //开启分页
            , cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                , {field: 'billId', title: '编号', width: 80, sort: true, fixed: 'left'}
                , {field: 'billTime', title: '账单产生时间', sort: true, width: 210}
                , {field: 'billMoney', title: '金额', width: 125}
                , {
                    field: 'billType', title: '类型', width: 90, templet: function (d) {
                        if (d.billType == 0){
                            return '<button type="button" class="layui-btn layui-btn-normal layui-btn-sm">支出</button>'
                        }else if(d.billType == 1){
                            return '<button type="button" class="layui-btn layui-btn-warm layui-btn-sm">收入</button>'
                        }
                    }
                }
                , {field: 'billAction', title: '事件', width: 450}
                , {field: 'billRest', title: '余额', width: 110}
            ]]
        });


        // 搜索
        $("#btn-seach").click(function () {
            // 获取搜索的数据
            var keyBillAction = $("input[name=keyBillAction]").val();
            var keywordBillType = $("select[name=keywordBillType]").val();

            var param = {
                billAction : keyBillAction,
                billType : keywordBillType,
            }

            // 重新加载表格
            tableIns.reload({
                where: param
            })
        });
    });


</script>

</body>

</html>